// 应急电话模型
const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const EmergencyPhone = sequelize.define('EmergencyPhone', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  name: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '电话名称'
  },
  phoneNumber: {
    type: DataTypes.STRING(20),
    allowNull: false,
    comment: '电话号码'
  },
  category: {
    type: DataTypes.STRING(50),
    allowNull: false,
    comment: '电话分类'
  },
  country: {
    type: DataTypes.STRING(50),
    allowNull: true,
    comment: '所属国家'
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '电话描述'
  },
  isCommon: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false,
    comment: '是否为常用电话'
  },
  order: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0,
    comment: '排序号'
  },
  status: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 1,
    comment: '状态 1:正常 2:禁用'
  },
  createdAt: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  },
  updatedAt: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  }
}, {
  tableName: 'emergency_phones',
  timestamps: true,
  charset: 'utf8mb4',
  collate: 'utf8mb4_unicode_ci'
});

module.exports = EmergencyPhone;